<!--
 * @Description: 动画系列
 * @author: 
 * @since: yyyy-MM-dd
 * @page: animation.vue
-->
<template>
  <div>
    <div class="box">
      <div class="ripple">
        <div class="dot"></div>
        <div class="circle1"></div>
        <div class="circle2"></div>
        <div class="circle3"></div>
      </div>
    </div>
    <!-- 广告动画 -->
    <div class="ad-animation" v-if="showHot">
      <el-icon @click="showHot = false"><CloseBold /></el-icon>
      <p>热点信息</p>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
const showHot = ref(true) //热点信息
</script>

<style lang="scss" scoped>
.box {
  position: relative;
  width: 30%;
  height: 400px;
  margin: 100px;
  background: url('@/assets/images/bcg.jpg');
  .ripple {
    position: absolute;
    top: 180px;
    left: 187px;
    > div {
      width: 20px;
      height: 20px;
      border-radius: 50%;
    }
  }
  //   固定背景
  .ripple .dot {
    background-color: aqua;
  }
  //波纹位于父元素中间，加阴影，不要背景，放大后四周扩散,属性选择器
  .ripple [class^='circle'] {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    box-shadow: 0 0 5px aqua; //只设置阴影
    animation: ripple 1.2s linear infinite;
  }
  //   circle直接走不用延迟，注意circle2,3的权重
  .ripple .circle2 {
    animation-delay: 0.4s;
  }
  .ripple .circle3 {
    animation-delay: 0.8s;
  }
}
@keyframes ripple {
  0% {
    // transform: scale(1); //不用缩放，因为会放大阴影
    // 0开始时，可以不设置动画
  }
  70% {
    width: 40px;
    height: 40px;
    opacity: 1;
  }
  100% {
    width: 70px;
    height: 70px;
    opacity: 0;
  }
}
.ad-animation {
  position: fixed;
  z-index: 99999;
  width: 200px;
  height: 100px;
  background-color: pink;
  cursor: pointer;
  //   animation: ad-animation 1s linear infinite;
  animation: float1 5s linear infinite;
  color: aqua;
  line-height: 100px;
  text-align: center;
  :deep(.el-icon) {
    position: absolute;
    font-size: 30px;
    color: aqua;
    font-weight: bold;
    margin-left: 72px;
    margin-top: 1px;
  }
  p {
    font-weight: bold;
    width: 100%;
    margin: 0;
    height: 50px;
  }
}
.ad-animation:hover {
  animation-play-state: paused;
}
// 从浏览器界面左侧中间，逆时针开始
@keyframes ad-animation {
  0% {
  }
  25% {
    transform: translate(100px, 0);
  }
  50% {
    transform: translate(100px, 100px);
  }
  75% {
    transform: translate(-100px, 100px);
  }
  100% {
    transform: translate(0, -100px);
  }
}
// 从浏览器界面左侧中间，顺时针开始
@keyframes float {
  0% {
    top: 50%;
    left: 0;
  }

  25% {
    top: calc(100% - 100px); //容器的高度，避免100%时，超出浏览器窗口
    left: 50%;
  }

  50% {
    top: 50%;
    left: calc(100% - 200px); //容器的宽度
  }

  75% {
    top: 0;
    left: 50%;
  }

  100% {
    top: 50%;
    left: 0;
  }
}
@keyframes float1 {
  0% {
    top: 50%;
    left: 0;
  }

  25% {
    top: 0;
    left: 50%;
  }

  50% {
    top: 50%;
    left: calc(100% - 200px);
  }

  75% {
    top: calc(100% - 100px);
    left: 50%;
  }

  100% {
    top: 50%;
    left: 0;
  }
}
</style>
